//
//  UIUtil.h
//  
//
//  Created by liuhui on 12-8-7.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import <AudioToolbox/AudioToolbox.h> 
#import <CoreGraphics/CoreGraphics.h>
#import <UIKit/UIKit.h>


@interface UIUtil : NSObject {
    
}
//针对audio获取其时间长度
+(CGFloat)voiceTimeForRowAtIndexPath:(NSString *)fileUri;

//获取登录账户plist信息
+ (NSMutableDictionary *)initAccountPlist;
//更新 账户信息
+ (void )updateAccountPlist:(NSDictionary *)account;
//获取一个试图，暂时用于背景填充的
+(UIView*)getAViewWithSize:(CGSize)si backGroundColor:(UIColor*)color;

///////////////////////////////////////////////////////////////////////////////////
//   create by Luo Ri Dong
+ (NSString *)timeFormatConvert:(NSDate *)date;

+ (UIColor *)colorWithRGBHex:(UInt32)hex withAlpha:(float)alpha;

+ (UIColor *)colorWithHexString:(NSString *)stringToConvert withAlpha:(float)alpha;

+ (NSString*)timeForCommentListStyle:(NSDate*) theDate;

+ (NSString*)timeForMessageListStyle:(NSDate*) theDate;

+ (NSString*)timeForMessageStyle:(NSDate *) theDate;

+ (NSString*)timeForMessageStyleNew:(NSDate *)theDate;

+ (NSString*)timeForParentChildRoomListStyle:(NSDate*) theDate;
///////////////////////////////////////////////////////////////////////////////////

+ (void)setBGImageViewForView:(UIView *)view imageName:(NSString *)name;

+ (void)addLineAtY:(CGFloat)y forView:(UIView *)view;

+ (void) showHintMessage:(NSString*) message withView:(UIView*) view;

+ (void) showHintMessage1:(NSString*) message withView:(UIView*) view;

+ (void) showAlertMessage:(NSString*)title message:(NSString*)message;

+ (void) showNetworkActivityIndicatorView:(UIView*) indicatorView show:(BOOL) show;

+ (BOOL) isHighResolutionDevice;

+ (BOOL) isLandScape;

/**
 * @desc judge whether the date is on current day
 * @return true or false
 */
+ (BOOL) isCurrentDay:(NSDate*)date;

+ (BOOL) isNetworkReachable;

+ (CGSize) textSizeWithFont:(UIFont*) font width:(CGFloat) width height:(CGFloat)height text:(NSString*)text lineBreakMode:(NSLineBreakMode)breakMode;

+ (NSString*) stringFromFomate:(NSDate*) date;

+ (NSString*) stringFromFomate:(NSDate*) date formate:(NSString*) formate;

+ (NSString *) stringYMDFromMillisecond:(NSString *)millisecond;

+ (NSString*) currentDateTimeYMDString;

+ (NSString*) currentDateTimeDetailString;

//return string format yyyy年MM月dd日星期几
+ (NSString*) currentDateTimeYMDWString;

+ (NSString*) getCurrentTimeWithFormatYMDHMS;

+ (NSString*) getYMDHMSDateString;

+ (NSString*) getYMDHMSUTCDateString;

+ (NSString*) getYMDHMString;

+ (NSString*) getHMString;

+ (NSString*) getHourFromDate:(NSDate*)date;

+ (NSString*) getMinuteFromDate:(NSDate*)date;

+ (NSString*) getDayFromDate:(NSDate*)date;

+ (NSString*) getMonthFromDate:(NSDate*)date;

+ (NSString*) getYearFromDate:(NSDate*)date;

//dateString must be yyyy-MM-dd HH:mm:ss format
+ (NSString*) intervalStringBetweenCurrentDateWithDateString:(NSString*)dateString;

+ (NSString*) md5:(NSString *)str;

+ (BOOL) hasPrefix:(NSString *)str prefix:(NSString*)prefix;


+ (NSString*) getImageSize:(UIImage*) image;

+ (CGFloat) getImageSizeOfKB:(UIImage*) image;

///time string should be yyyy-mm-dd format
+ (NSString*) getYearMonthDayString:(NSString*)timeString;

+ (NSDate*) currentDate;

+ (NSDate*) dateFromFormat:(NSString*) timeString formate:(NSString*) formate;

+ (UIImage *)setImageSize:(CGFloat)width imageName:(NSString *)imageName;

+ (UIImage *)setImageWidth:(CGFloat)width height:(CGFloat)height imageName:(NSString *)imageName;

+ (UIImage*)captureView:(UIView *)theView;

//+ (UIImage*) contactPicture:(ABRecordRef)person;
//
//+ (ABRecordID) getMaxABRecordId;
//liuhui ++
+ (NSString*)currentTime;

+ (BOOL) currTimeInStartTime:(NSString*)startTime andEndTime:(NSString*)endTime;

+ (NSString*) ConvertFullFilePath:(NSString *)strBodyFile fileType:(NSInteger)type;

+ (NSString*) GetOldFullFilePath:(NSString *)strBodyFile;

+ (NSString*) GetOnlyFileName:(NSString *)strBodyFile;

+(BOOL) moveCssFile:(NSInteger)csstype;

+(NSString*) MimeStringDateToStringDate:(NSString*) mimeDateStr;

+(NSInteger) moveFileFrom:(NSString*)oldPath to:(NSString*)newPath;

+(BOOL) fileExistAtDocPath:(NSString*)fileName;

+(NSString*) filterDayString:(NSString*)dayStr;

+(NSString*) AddDayString:(NSString*)dayStr;

+(NSInteger) getScreenWidth;

+(NSInteger) getScreenWidth2;

+(NSInteger) getiOSSystemVersion;

+(NSString*) getDocumentPath;

+(NSString *)getTempPath:(NSString*)filename;

+(BOOL)isFileExist:(NSString *)filepath;

+(BOOL)copyFile:(NSString*)srcPath to:(NSString*)dstPath;

+(NSString*)getValidEndTime:(NSString*)startTime EndTime:(NSString*)endTime;

+(NSString*)getValidStartTime:(NSString*)startTime EndTime:(NSString*)endTime;

+(void) PostNotificationName:(NSString*)notificationName Object:(id)object Key:(id)key;

+(NSDictionary*)getFileAttributes:(NSString *)filePath;

+(NSString *)getSystemTime:(NSDate*)date;
+(NSDate*)antiGetSystemTime:(NSString*)strDate;


+(NSString*)getServerId:(NSString*)emailAddress;

+(NSString*)getDomain:(NSString*)emailAddress;

+(NSArray *)filterDomainAddress:(NSString *)emailAddress;

+(NSString*)getDomainSuffix:(NSString*)emailAddress;

+(void)createAppPrivatePaths;
//添加转圈等待，
+(void)addMBProgressViewTitle:(NSString*)title inView:(UIView*)view alpha:(CGFloat)al failureTitle:(NSString *)failureTitle;

+(void)addMBProgressViewNoNetWorcCheckTitle:(NSString*)title inView:(UIView*)view alpha:(CGFloat)al failureTitle:(NSString *)failureTitle;

+(void)addMBProgressViewTitle:(NSString*)title inView:(UIView*)view alpha:(CGFloat)al hideDelayTime:(NSTimeInterval)time failureTitle:(NSString *)failureTitle;
//隐藏转圈的等待
+(void)hideMBProgressViewForView:(UIView*)view;

+(BOOL)MBProgressViewForView:(UIView*)view;
//添加AlertView
+(void)addAlertViewTitle:(NSString*)title message:(NSString*)message delegate:(id)target cancelButtonTitle:(NSString*)cancelBtn otherBtnTitle:(NSString*)other;

+ (UIImage*)scaleFromImage:(UIImage*)image scaledToWidth:(CGFloat)newWidth;

//zhuxuehang
//消息提醒设置
//设置消息提醒
+(void)setMessageAlertFlag:(BOOL)flag;      //通知栏消息提醒设置
+(void)setNotificationAlertFlag:(BOOL)flag; //通知声音设置
+(void)setVibrateAlertFlag:(BOOL)flag;      //震动设置
//获取
+(BOOL)getMessageAlertFlag;                 //通知栏消息提醒
+(BOOL)getNotificationAlertFlag;            //通知声音
+(BOOL)getVibrateAlertFlag;                 //震动
//三种声音的播放
+(SystemSoundID)playSystemSoundForMessage;       //信息声音
+(void)playSystemSoundForNotification;  //通知声音
+(void)playSystemAlert;                 //震动
//免打扰时间段类型获取
+(void)setNoDisturbType:(uint)flag;     //设置免打扰类型
+(NO_DISTURB_TIME)getNoDisturbType;     //获取免打扰类型
//其他界面只需调用此方法即可
+(void)playSound;       //播放声音，已经做是否播放的处理，有消息来的时候，可以直接调用该方法

+(void)playWave;
//发送声音 松开声音
+(void)playSoundForVoiceSongKai;

//发送声音  按下声音
+(void)playSoundForVoiceAnXia;
+(void)playSoundForVoiceAnXia:(AudioServicesSystemSoundCompletionProc)proc;


//发送声音  声音发送成功
+(void)playSoundForVoiceSuccess;

+(void)createFilePath:(NSString *)filePath;

+(void)LogToFile:(NSString *)content;


+(NSString *)getStrByDate:(NSInteger)index;

+(void)delOldLog;

+ (NSString *)getFileIconByName:(NSString *)fileName;

+ (NSString *)getChatFileIconByName:(NSString *)fileName;
+ (NSArray *)handleDirPathWithPath:(NSString *)path;
+ (NSArray *)handleFilePathWithPath:(NSString *)path isGroup:(BOOL)isGroup;
+ (NSString *)getFileNameWithServerFileName:(NSString *)serverFileName;
+ (NSString *)getGroupFileNameWithServerFileName:(NSString *)serverFileName;
+ (NSString *)getOverdueYMDHMSDateStringWithTimeStamp:(NSDate *)date;


+ (NSString *)getCurrentTimeStamp;


+ (NSDateComponents *)getCurdateComponents;


+ (NSAttributedString *)timeForMineShareListStyle:(NSDate*) theDate;

+ (NSString *)timeForNewCommentListStyle:(NSDate*) theDate;
@end

